package com.superwein.dubbo.consumer.controller;

import com.superwein.dubbo.api.service.DemoService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    @DubboReference(registry = {"shanghai", "beijing"},
            loadbalance = "consistenthash",
            cluster = "failover",
            retries = 0,
            check = false,
            timeout = 500,
            mock = "com.superwein.dubbo.consumer.downgrade.DemoServiceMock")
    private DemoService demoService;

    @GetMapping(value = "/sayHello")
    public String sayHello(String name) {
        return demoService.sayHello(name);
    }

}
